package ${package.ServiceImpl};

import ${package.Entity}.${entity};
import ${package.Mapper}.${table.mapperName};
import ${package.Service}.${table.serviceName};
import ${superServiceImplClassPackage};
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.cg.common.core.utils.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import java.util.List;
import javax.annotation.Resource;

/**
* <p>
    * ${table.comment!} 服务实现类
    * </p>
*
* @author lzw
*/
@Service
<#if kotlin>
open class ${table.serviceImplName} : ${superServiceImplClass}<${table.mapperName}, ${entity}>(), ${table.serviceName} {

}
<#else>
public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.mapperName}, ${entity}> implements ${table.serviceName} {

@Resource
private ${table.mapperName} ${table.mapperName?uncap_first};

/**
* ${table.comment!}分页列表
* @param param 根据需要进行传值
* @return
*/
@Override
public IPage<${entity}> page(${entity} param,Integer pageCurrent, Integer pageSize,Boolean sort, String sortName) {

QueryWrapper<${entity}> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda()
<#list table.fields as field>
    // ${field.comment}
    <#if !entityLombokModel>
        <#if field.propertyType == "Boolean">
            <#assign getprefix="is"/>
        <#else>
            <#assign getprefix="get"/>
        </#if>
        <#if field.propertyType == "String">
            .eq(StringUtils.isNotBlank(param.${getprefix}${field.capitalName}()), ${entity}::${getprefix}${field.capitalName}, param.${getprefix}${field.capitalName}())
        <#else>
            .eq(param.${getprefix}${field.capitalName}() != null, ${entity}::${getprefix}${field.capitalName}, param.${getprefix}${field.capitalName}())
        </#if>
    <#else>
        <#if field.propertyType == "String">
            .eq(StringUtils.isNotBlank(param.get${field.capitalName}()), ${entity}::get${field.capitalName}, param.get${field.capitalName}())
        <#else>
            .eq(param.get${field.capitalName}() != null, ${entity}::get${field.capitalName}, param.get${field.capitalName}())
        </#if>
    </#if>
</#list>;
if(StringUtils.isBlank(sortName)){
queryWrapper.orderByDesc("update_time");
}else {
if(sort){
queryWrapper.orderByAsc(sortName);
}else{
queryWrapper.orderByDesc(sortName);
}
}
IPage<${entity}> page = page(new Page<>(pageCurrent,pageSize), queryWrapper);
return page;
}

/**
* ${table.comment!}详情
* @param id
* @return
*/
@Override
public ${entity} info(Long id) {
return getById(id);
}

/**
* ${table.comment!}新增(单个新增)
* @param param 根据需要进行传值
* @return
*/
@Override
public void add(${entity} param) {
save(param);
}

/**
* ${table.comment!}新增(批量新增)
* @param param 根据需要进行传值
* @return
*/
@Override
public void adds(List<${entity}> param) {
saveBatch(param,param.size());
}

/**
* ${table.comment!}修改(单个修改)
* @param param 根据需要进行传值
* @return
*/
@Override
public void modify(${entity} param) {
updateById(param);
}

/**
* ${table.comment!}修改(批量修改)
* @param param 根据需要进行传值
* @return
*/
@Override
public void modifys(List<${entity}> param) {
updateBatchById(param,param.size());
}

/**
* ${table.comment!}删除(单个条目)
* @param id
* @return
*/
@Override
public void remove(Long id) {
removeById(id);
}

/**
* ${table.comment!}删除(多个条目)
* @param ids
* @return
*/
@Override
public void removes(List
<Long> ids) {
    removeByIds(ids);
    }
    }
    </#if>
